package seedpod.kb2db.protegeplugin;
/**
 * Copyright 2009 University of  Washington
 * This code is released under the GPL version 3 - with a copy of the license included
 * @author Maya Hao Li
 *
 */
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.File;

import javax.swing.JEditorPane;
import javax.swing.JFrame;

public class EditorContentKeyListener extends KeyAdapter
{
	private JFrame _frame;
	private JEditorPane _editor;
	private File _file;
	private boolean windowListenerAdded = false;

	public EditorContentKeyListener(JFrame container, JEditorPane editor, File srcfile) {
		_frame = container;
		_editor = editor;
		_file = srcfile;
	}
	
	public void keyTyped( KeyEvent e ) {
		addWindowListener();
	}
	
	public void addWindowListener() {
		if (!windowListenerAdded ) {
		_frame.addWindowListener( new PromptSaveUponDocumentCloseListener( _editor, _file ) );
		windowListenerAdded = true;
		}
	}
	
}
